import type { Router } from 'vue-router';
import { setRouteEmitter } from '@/utils/route-listener';
import NProgress from 'nprogress'; // progress bar
// import setupPermissionGuard from './permission';


function setupPageGuard(router: Router) {
  router.beforeEach(async (to) => {
    // emit route change
    NProgress.start();
    setRouteEmitter(to);
    NProgress.done();
  });
}

export default function createRouteGuard(router: Router) {
  setupPageGuard(router);
  // if(import.meta.env.VITE_USE_MOCK) setupPermissionGuard(router);
}
